Relay 5 Click
Relay 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Mar 2023.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of Relay 5 Click board by toggling the relays state.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Relay5
Example Key Functions
- relay5_cfg_setup Config Object Initialization function.
void relay5_cfg_setup(relay5_cfg_t *cfg)
Relay 5 configuration object setup function.
Relay 5 Click configuration object.
Definition relay5.h:167
- relay5_init Initialization function.
err_t relay5_init(relay5_t *ctx, relay5_cfg_t *cfg)
Relay 5 initialization function.
Relay 5 Click context object.
Definition relay5.h:150
- relay5_default_cfg Click Default Configuration function.
err_t relay5_default_cfg(relay5_t *ctx)
Relay 5 default configuration function.
- relay5_set_relay1_open This function sets the relay 1 to normally open state by setting the RL1 pin to low logic level.
err_t relay5_set_relay1_open(relay5_t *ctx)
Relay 5 set relay 1 open function.
- relay5_set_relay1_close This function sets the relay 1 to normally close state by setting the RL1 pin to high logic level.
err_t relay5_set_relay1_close(relay5_t *ctx)
Relay 5 set relay 1 close function.
- relay5_switch_relay1 This function switches the relay 1 state by toggling the RL1 pin logic level.
err_t relay5_switch_relay1(relay5_t *ctx)
Relay 5 switch relay 1 function.
Application Init
Initializes the driver and logger.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
relay5_init( &relay5, &relay5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define RELAY5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition relay5.h:137
void application_init(void)
Definition main.c:31
#define MIKROBUS_POSITION_RELAY5
Definition main.c:25
@ RELAY5_ERROR
Definition relay5.h:185
Application Task
Switches all relays state every 5 seconds and displays the state on the USB UART.
{
log_printf( &logger, " Relay 1 set to normally open state\r\n" );
log_printf( &logger, " Relay 2 set to normally close state\r\n" );
log_printf( &logger, " Relay 3 set to normally open state\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " Relay 1 set to normally close state\r\n" );
log_printf( &logger, " Relay 2 set to normally open state\r\n" );
log_printf( &logger, " Relay 3 set to normally close state\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
err_t relay5_set_relay3_close(relay5_t *ctx)
Relay 5 set relay 3 close function.
err_t relay5_set_relay2_close(relay5_t *ctx)
Relay 5 set relay 2 close function.
err_t relay5_set_relay2_open(relay5_t *ctx)
Relay 5 set relay 2 open function.
err_t relay5_set_relay3_open(relay5_t *ctx)
Relay 5 set relay 3 open function.
void application_task(void)
Definition main.c:67
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.